<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/12/21
 * Time: 16:52
 */

namespace app\crm\model;


use think\Db;

class GameModel
{
    public static $table = 'game';

    public static function pagination($where = [], $pageSize)
    {
        $db = Db::name(self::$table);
        $db->order('order_id', 'desc');
        return $db->paginate($pageSize);
    }

    public static function insert($data)
    {
        return Db::name(self::$table)->insert($data);
    }

    public static function one($where = [])
    {
        $db = Db::name(self::$table);
        if (isset($where['id'])) {
            $db->where('id', $where['id']);
        }
        if (isset($where['name'])) {
            $db->where('name', $where['name']);
        }
        return $db->limit(1)->find();
    }

    public static function update($where, $data)
    {
        return Db::name(self::$table)->where($where)->update($data);
    }
}